{% extends 'base.html' %}
{% block content %}
  <section>
    <h2>搜索规则</h2>
    <form method="get">
      <input type="text" name="q" value="{{ q }}" placeholder="关键词" />
      <button type="submit">搜索</button>
    </form>
    {% if q %}
      <h3>结果（目录：rules/）</h3>
      {% if results|length == 0 %}
        <p>无匹配项。</p>
      {% else %}
        <ul>
        {% for item in results %}
          <li><code>{{ item.file }}</code>: 第 {{ item.line }} 行 - {{ item.text }}</li>
        {% endfor %}
        </ul>
      {% endif %}
    {% endif %}
  </section>
{% endblock %}

